package com.wys.mall.search.webcontroller;

import com.wys.mall.search.service.MallSearchService;
import com.wys.mall.search.vo.SearchParam;
import com.wys.mall.search.vo.SearchResult;
import org.elasticsearch.search.SearchService;
import org.redisson.api.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import sun.net.httpserver.HttpServerImpl;

import javax.servlet.http.HttpServletRequest;

/**
 * 页面跳转
 *
 * @Package com.wys.mall.product.webcontroller
 * @Author charlin
 * @Version: v1.0
 * @Date 2021-06-2610:28
 * @Copyright: 2021 www.wyscha.com Inc. All rights reserved.
 */
@Controller
public class IndexController {

    @Autowired
    private RedissonClient redissonClient;
    @Autowired
    private MallSearchService searchService;
    /**
     * 跳转到首页
     *
     * @return
     */
    @GetMapping({ "/list.html", "/list"})
    public String indexPage(Model model, SearchParam searchParam, HttpServletRequest request) {
        searchParam.set_queryString(request.getQueryString());
        SearchResult searchResult = searchService.search(searchParam);
        model.addAttribute("result", searchResult);
        return "list";
    }

}
